import modules from './modules'
import Vue from 'vue'
import Router from '@/uni_modules/uni-simple-router/index.js'
import store from '@/store/index.js'

Vue.use(Router)
//初始化
const router = new Router({
	encodeURI:true,  
    routes: [...modules]//路由表
});

//全局路由前置守卫
router.beforeEach((to, from, next) => {
	let token=store.state.vuex_token
	if(token){
		 next()
	}else{
		if (to.meta.noLogin) {
		  next()
		}else{
		  next({ path: `/pages/login/login`})
		}
	} 
})
// 全局路由后置守卫
router.afterEach((to, from) => {
	//console.log("afterEach")
})
export default router;